package cn.assumejson.springframework.beans.context.support;

import cn.assumejson.springframework.beans.context.ApplicationContext;
import cn.assumejson.springframework.beans.factory.support.DefaultListableBeanFactory;
import cn.assumejson.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import cn.assumejson.springframework.core.io.Resource;

/**
 * 在上下稳重对配置信息的加载
 * xml的方式
 *
 * @author Mr. Li
 * @version 1.0
 * @since 1.0 2021/11/30 15:53
 */
public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext {
    // 获取XML，获得xml路径资源解析器
    public AbstractXmlApplicationContext(ApplicationContext parent) {
        super(parent);
    }

    @Override
    protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory, this);
        //读取配置
        for (String configLocation : this.getConfigLocations()) {
            reader.loadBeanDefinitions(configLocation);
        }
    }
}
